package com.java.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.java.po.User;
import com.java.po.UserCustom;
import com.java.po.UserMap;
import com.java.service.UserService;
import com.java.service.impl.UserServiceImpl;
import com.java.tool.AjaxJson;


/**
 * Title:UserController.java
 * Description:
 * @author:sprogrammer
 * @time:2018年1月18日下午5:17:23
 */

@Controller
@CrossOrigin()
@RequestMapping(method=RequestMethod.POST)
public class UserController {
	
	private AjaxJson ajaxJson;
	
	@RequestMapping(value="/Userlogin")
	public @ResponseBody AjaxJson login(@RequestBody User user) throws Exception{
		UserService service = new UserServiceImpl();
		ajaxJson = service.LoginUser(user);
		return ajaxJson;
	}
	
	@RequestMapping(value="/findUserByid")
	public @ResponseBody AjaxJson findUserByid(@RequestBody User user) throws Exception{
		UserService service = new UserServiceImpl();
		ajaxJson = service.findUserByid(user);
		return ajaxJson;
	}
	
	@RequestMapping(value="/DeleteUser")
	public @ResponseBody AjaxJson DeleteUser(@RequestBody User user) throws Exception{
		UserService service = new UserServiceImpl();
		ajaxJson = service.delete(user);
		return ajaxJson;
	}
	

	@RequestMapping(value="/updataUser")
	public @ResponseBody AjaxJson updataUser(UserCustom userCustom) throws Exception{
		UserService service = new UserServiceImpl();
		
		ajaxJson  = service.updateUser(userCustom);
		return ajaxJson;
	}
	@RequestMapping(value="/insertUser")
	public @ResponseBody AjaxJson insertUser(UserCustom userCustom) throws Exception{
		UserService service = new UserServiceImpl();
		ajaxJson  = service.insertUser(userCustom);
		return ajaxJson;
	}
	@RequestMapping(value="/findAllUser")
	public @ResponseBody AjaxJson findAllUser(@RequestBody UserMap usermap) throws Exception{
		UserService service = new UserServiceImpl();
		ajaxJson  = service.fingAllUser(usermap);
		return ajaxJson;
	}

}
